import request from '@/config/axios'

// 医院 VO
export interface HospitalVO {
  id: number // id
  name: string // 名称
  label: string // 类型,三甲，专科，综合等
  department: string // 重点科室
  intro: string // 医院简介
  provinceCode: number // 省编码
  province: string // 省
  cityCode: number // 市编码
  city: string // 市
  address: string // 详细地址
  coordinate: string // 经纬度
  cover: string // 背景
  icon: string // 缩略图
  sort: number // 排序（由小到大）
}

// 医院 API
export const HospitalApi = {
  // 查询医院分页
  getHospitalPage: async (params: any) => {
    return await request.get({ url: `/peizhen/hospital/page`, params })
  },

  // 查询医院详情
  getHospital: async (id: number) => {
    return await request.get({ url: `/peizhen/hospital/get?id=` + id })
  },

  // 新增医院
  createHospital: async (data: HospitalVO) => {
    return await request.post({ url: `/peizhen/hospital/create`, data })
  },

  // 修改医院
  updateHospital: async (data: HospitalVO) => {
    return await request.put({ url: `/peizhen/hospital/update`, data })
  },

  // 删除医院
  deleteHospital: async (id: number) => {
    return await request.delete({ url: `/peizhen/hospital/delete?id=` + id })
  },

  // 导出医院 Excel
  exportHospital: async (params) => {
    return await request.download({ url: `/peizhen/hospital/export-excel`, params })
  },

// ==================== 子表（医院科室） ====================

  // 获得医院科室分页
  getSectionPage: async (params) => {
    return await request.get({ url: `/peizhen/hospital/section/page`, params })
  },
  // 新增医院科室
  createSection: async (data) => {
    return await request.post({ url: `/peizhen/hospital/section/create`, data })
  },

  // 修改医院科室
  updateSection: async (data) => {
    return await request.put({ url: `/peizhen/hospital/section/update`, data })
  },

  // 删除医院科室
  deleteSection: async (id: number) => {
    return await request.delete({ url: `/peizhen/hospital/section/delete?id=` + id })
  },

  // 获得医院科室
  getSection: async (id: number) => {
    return await request.get({ url: `/peizhen/hospital/section/get?id=` + id })
  },
}